<template>
	<view class="wode">
		<div class="wode_top">
			<div class="wode_top_cont">
				<div class="wode_top_cont_left">
					<div class="wode_top_cont_left_top">
						{{userInfo.nickname || ''}}
					</div>
					<div class="wode_top_cont_left_bottom">
						{{userInfo.phone || ''}}
					</div>
				</div>
				<div class="wode_top_cont_right">
					<image :src="userInfo.avatar_url" mode=""></image>
				</div>
			</div>
		</div>
		<!-- 点击切换 -->
		<div class="wode_list_ite">
			<div class="wode_list_ite_items" v-for="(ite,idx) in wdList" :key="idx" @click='routerEvent(ite.url)'>
				<div class="wode_list_ite_items_img">
					<image :src="ite.img" mode=""></image>
				</div>
				<div class="wode_list_ite_items_cont" :class="idx == wdList.length - 1 ?'borderNone':''">
					<div class="wode_list_ite_items_cont_left">
						{{ite.name}}
					</div>
					<div class="wode_list_ite_items_cont_right">
						<!-- <image src="https://wx.sjcmhz.com/static/logo.png" mode=""></image> -->
						<u-icon slot="right" name="arrow-right" color='#C9C9C9'></u-icon>
					</div>
				</div>
			</div>
		</div>
		<div id="tabar">
			<tabar :value4='4'></tabar>
		</div>
	</view>
</template>

<script>
	import tabar from '@/pagesA/components/tabar.vue'
	export default {
		components: {
			tabar
		},
		data() {
			return {
				title: 'Hello',
				list: [{
					name: '待处理服务',
					num: 1
				}, {
					name: '待签到课程',
					num: 10
				}, {
					name: '待评价',
					num: 12
				}],
				wdList: [{
					img: 'https://wx.sjcmhz.com/static/image/pageA/xzwd4.png',
					name: '课程记录',
					url: "myPage/classList"
				}, 
				// {
				// 	img: 'https://wx.sjcmhz.com/static/image/pageA/xzwd3.png',
				// 	name: '我的排班',
				// 	url: 'myPage/paiban'
				// }, 
				{
					img: 'https://wx.sjcmhz.com/static/image/pageA/xzwd2.png',
					name: '楼长通讯录',
					url: 'myPage/contract'
				}, {
					img: 'https://wx.sjcmhz.com/static/image/pageA/xzwd1.png',
					name: '扫码核销',
					url: '扫码'
				}],
				userInfo: {}
			}
		},
		onLoad() {
			this.getUserInfo()
		},
		methods: {
			async getUserInfo() {
				const {
					data
				} = await this.$request(this.$Api.personUser, {

				}, "POST")
				if (data.code !== 0) return
				this.userInfo = data.data.user
				// this.list[0].num = data.data.notice
				// this.list[1].num = data.data.class
				// this.list[2].num = data.data.comment
			},
			routerEvent(url) {
				if (url == '扫码') {
					this.scanQRCode()
				} else {
					uni.navigateTo({
						url: url
					})
				}

			},
			scanQRCode() {
				let that = this
				uni.scanCode({
					success: (res) => {
						console.log('扫码结果：' + res.result);
						that.sendCode(res.result)
					},
					fail: (err) => {
						console.error('扫码失败：' + err);
						uni.showToast({
							title: '扫码失败',
							icon: 'none'
						});
					}
				});
			},
			// 核销
			async sendCode(code) {
				const {
					data
				} = await this.$request(this.$Api.personCode, {
					code:code
				}, "POST")
				if (data.code !== 0) return
				uni.showToast({
					title: '核销成功',
					icon: 'none'
				});
			}
		}
	}
</script>




<style lang="scss">
	.wode {
		background: #F5F5F5;
		min-height: 100vh;
	}

	.wode_top {
		width: 750rpx;
		height: 210rpx;
		background: #2E61FF;
		font-size: 36rpx;
		color: #fff;
		position: relative;

		.wode_top_cont {
			width: 100%;
			height: 100%;
			display: flex;
			// align-items: center;
			justify-content: space-between;
			padding: 48rpx 38rpx 14rpx 38rpx;
			box-sizing: border-box;

			.wode_top_cont_left_bottom {
				width: 186rpx;
				height: 50rpx;
				// background: #FFFFFF;
				border-radius: 25rpx;
				color: #fff;
				font-size: 22rpx;
				text-align: left;
				line-height: 50rpx;
				margin-top: 18rpx;
			}

			.wode_top_cont_right {
				width: 116rpx;
				height: 116rpx;
				border: 6rpx solid #FFFFFF;
				border-radius: 50%;
				box-sizing: border-box;

				image {
					width: 100%;
					height: 100%;
					border-radius: 50%;
				}

			}
		}

		.wode_top_cont_bottom {
			width: 704rpx;
			height: 162rpx;
			background: #3F0077;
			position: absolute;
			left: 22rpx;
			bottom: 0;
			padding: 44rpx;
			box-sizing: border-box;
			font-size: 32rpx;
			line-height: 44rp;
			display: flex;
			justify-content: space-between;
			align-items: center;

		}

		.wode_top_cont_bottom_left_bottom {
			font-size: 24rpx;
			margin-top: 8rpx;
			opacity: 0.8;
		}

		.wode_top_cont_bottom_right {
			width: 154rpx;
			height: 44rpx;
			background: #3F0077;
			border-radius: 12rpx;
			border: 2rpx solid #F5A623;
			font-size: 24rpx;
			color: #F5A623;
			text-align: center;
			line-height: 42rpx;
		}
	}

	.wode_top_num {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 180rpx;
		width: 100%;
		padding: 0 22rpx 0 20rpx;
		box-sizing: border-box;
		margin-bottom: 20rpx;
		background: #fff;

		.wode_top_num_items {
			width: 33%;
		}

		.wode_top_num_title {
			font-size: 52rpx;
			color: #9013FE;
			text-align: center;
		}

		.wode_top_num_bottom {
			font-size: 28rpx;
			margin-top: 14rpx;
			text-align: center;
		}

		.wode_top_num_bottom_index {
			padding-left: 20rpx;
		}

	}

	.wode_list_ite {
		width: 100%;
		height: auto;
		background: #fff;
		padding: 10rpx 34rpx 0rpx 34rpx;
		margin-top: 22rpx;
		box-sizing: border-box;

		image {
			width: 40rpx;
			height: 40rpx;
		}

		.wode_list_ite_items {
			width: 100%;
			height: 96rpx;
			display: flex;
			align-items: center;

			.wode_list_ite_items_img {
				width: 35rpx;

				image {
					width: 35rpx;
					margin-right: 20rpx;
				}
			}
		}

		.wode_list_ite_items_cont {
			display: flex;
			justify-content: space-between;
			align-items: center;
			border-bottom: 2rpx solid #DDDDDD;
			width: 620rpx;
			margin-left: 20rpx;
			height: 100%;
			font-size: 32rpx;

			.wode_list_ite_items_cont_right {
				image {
					width: 28rpx;
					height: 28rpx;
				}
			}

		}

		.borderNone {
			border: none;
		}

	}
</style>